Skip to content

fix: add usage tracking to config method #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Aug 14, 2025

Tracking internally in SDK-1414.

Add usage tracking to config method

This PR implements SDK spec requirement 1.2.3.5 by adding usage tracking to the config method across all AI SDK repositories, following the pattern established in JS Core PR #904.

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions ⚠️ See testing notes below

Related issues

Describe the solution you've provided

Added a single tracking call track('$ld:ai:config:function:single', context, key, 1) at the beginning of each config method across all 4 AI SDK repositories:

  • Ruby: @ld_client.track('$ld:ai:config:function:single', context, config_key, 1)
  • Python: self._client.track('$ld:ai:config:function:single', context, key, 1)
  • Go: c.sdk.TrackMetric("$ld:ai:config:function:single", context, 1, ldvalue.String(key))
  • .NET: _client.Track("$ld:ai:config:function:single", context, LdValue.Of(key), 1)

Each implementation includes a corresponding unit test to verify the tracking call is made with the correct parameters.

Critical Review Points

⚠️ Testing Limitations: Due to local environment setup constraints, I was unable to run the full test suites locally. The tests were written based on existing patterns but should be verified to pass in the proper CI environment.

🔍 Key Items to Review:

  1. Tracking method signatures: Each SDK uses different tracking APIs - verify parameter order and types are correct
  2. Event consistency: Confirm the event name $ld:ai:config:function:single is exactly as specified
  3. Method placement: Tracking call is added at the beginning of each config method - verify this is the intended location
  4. Test validity: Run tests to ensure they pass and properly verify the tracking functionality

Describe alternatives you've considered

  • Considered placing tracking calls after input validation, but chose to place them at method entry to ensure all invocations are tracked
  • Each SDK's tracking implementation follows its existing patterns rather than trying to standardize the approach

Additional context

Cross-SDK Implementation Details

SDK Tracking Method Parameter Order
Ruby track(event, context, key, value) Standard LaunchDarkly pattern
Python track(event, context, key, value) Standard LaunchDarkly pattern
Go TrackMetric(event, context, value, data) Go-specific metric tracking
.NET Track(event, context, data, value) .NET-specific parameter order

- Add tracking call for :ai:config:function:single event
- Include test to verify tracking functionality
- Follows SDK spec requirement 1.2.3.5

Co-Authored-By: [email protected] <[email protected]>
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 3 commits August 14, 2025 14:47
- Add trailing comma to hash literal
- Remove trailing whitespace
- Use receive instead of have_received for RSpec message expectations

Co-Authored-By: [email protected] <[email protected]>
- Use have_received instead of receive for post-call verification
- Fixes test failure in config method tracking test

Co-Authored-By: [email protected] <[email protected]>
- Follow existing test pattern using receive instead of have_received
- Ensure consistency with other tests in the file
- Fixes RuboCop MessageSpies offense

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration devin-ai-integration bot changed the title Add usage tracking to config method fix: add usage tracking to config method Aug 14, 2025
@jsonbailey jsonbailey marked this pull request as ready for review August 15, 2025 14:08
@jsonbailey jsonbailey requested a review from a team as a code owner August 15, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants